package com.learn.canal;

import com.alibaba.fastjson.JSON;
import com.learn.domain.User;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

/**
 * @author: tzj
 * @create: 2022-08-16
 **/
@CanalTable(value = "t_user")
@Component
public class UserHandler implements EntryHandler<User> {

    @Override
    public void insert(User user) {
        System.out.println("insert操作：" + JSON.toJSONString(user));
    }

    @Override
    public void update(User before, User after) {
        System.out.println("update操作前：" + JSON.toJSONString(before));
        System.out.println("update操作后：" + JSON.toJSONString(after));
    }

    @Override
    public void delete(User user) {
        System.out.println("del操作：" + JSON.toJSONString(user));
    }
}
